<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-collapse v-model="activeKey">
            <a-collapse-panel key="1" header="付款单-单据头">
        <a-row :gutter="48">
          <a-col :span="8">
            <a-form-model-item label="单据类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fbilltypeid">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fbilltypeiddata" dictCode="f_bill_type_id" placeholder="请选择单据类型" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="单据编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fbillno">
              <a-input  style="color: #1890FF; cursor: pointer;"  v-model="model.fbillno" :max-length="36"  placeholder="请输入单据编号" readOnly @click.prevent="goDetail(model)"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="付款申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fxyhgbase">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fxyhgbase" dictCode="erp_employee_file,name,employee_no" placeholder="请选择付款申请人" disabled/>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="8">
            <a-form-model-item label="审核人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fapproverid">
              <a-input :disabled=formDisabled v-model="model.fapproveriddata" :max-length="36"  placeholder="请输入审核人"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="8">
            <a-form-model-item label="创建日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fcreatedate">
              <j-date
                    :disabled="formDisabled"
                    placeholder="请选择创建日期"
                    v-model="model.fcreatedate"
                    :show-time="true"
                    date-format="YYYY-MM-DD HH:mm:ss"
                    style="width: 100%"
                    disabled
                  />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="付款组织" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpayorgiddata">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fpayorgiddata" dictCode="erp_company_files,file_name,kingdee_org_id" placeholder="请选择付款组织" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="结算组织" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fsettleorgid">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fsettleorgiddata" dictCode="erp_company_files,file_name,kingdee_org_id" placeholder="请选择结算组织" disabled/>
              <!-- <a-input :disabled=formDisabled v-model="model.fsettleorgiddata" :max-length="36"  placeholder="请输入结算组织"  ></a-input> -->
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="8">
            <a-form-model-item label="审核日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fapprovedate">
              <j-date :disabled=formDisabled placeholder="请选择审核日期" v-model="model.fapprovedate"  style="width: 100%" />
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="采购组织" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpurchaseorgiddata">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fpurchaseorgiddata" dictCode="erp_company_files,file_name,kingdee_org_id" placeholder="请选择采购组织" disabled/>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="8">
            <a-form-model-item label="业务日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fdate">
              <j-date
                    :disabled="formDisabled"
                    placeholder="请选择业务日期"
                    v-model="model.fdate"
                    :show-time="true"
                    date-format="YYYY-MM-DD HH:mm:ss"
                    style="width: 100%"
                    disabled
                  />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="应付金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpaytotalamountforH">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpaytotalamountforH" placeholder="请输入应付金额" style="width: 100%" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="实付金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frealpayamountforH">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.frealpayamountforH" placeholder="请输入实付金额" style="width: 100%" disabled/>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="8">
            <a-form-model-item label="会计核算体系" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="faccountsystem">
              <a-input :disabled=formDisabled v-model="model.faccountsystem" :max-length="36"  placeholder="请输入会计核算体系"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="8">
            <a-form-model-item label="往来单位类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fcontactunittype">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fcontactunittype" dictCode="f_contact_unit_type" placeholder="请选择往来单位类型" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="往来单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fcontactunit">
              <j-dict-select-tag :disabled=formDisabled type="list" v-if="model.fcontactunittype=='BD_Supplier'" v-model="model.fcontactunitdata" dictCode="erp_finance_kingdee_base_supplier_info,fname,fnumber" placeholder="请选择往来单位" disabled/>
              <j-dict-select-tag :disabled=formDisabled type="list" v-else-if="model.fcontactunittype=='BD_Customer'" v-model="model.fcontactunitdata" dictCode="erp_finance_kingdee_base_custom_info,fname,fnumber" placeholder="请选择往来单位" disabled/>
              <j-dict-select-tag :disabled=formDisabled type="list" v-else-if="model.fcontactunittype=='BD_Empinfo'" v-model="model.fcontactunitdata" dictCode="erp_employee_file,name,employee_no" placeholder="请选择往来单位" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="收款单位类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frectunittype">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.frectunittype" dictCode="f_contact_unit_type" placeholder="请选择收款单位类型" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="收款单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frectunit">
              <j-dict-select-tag :disabled=formDisabled type="list" v-if="model.frectunittype=='BD_Supplier'" v-model="model.frectunitdata" dictCode="erp_finance_kingdee_base_supplier_info,fname,fnumber" placeholder="请选择收款单位" disabled/>
              <j-dict-select-tag :disabled=formDisabled type="list" v-else-if="model.frectunittype=='BD_Customer'" v-model="model.frectunitdata" dictCode="erp_finance_kingdee_base_custom_info,fname,fnumber" placeholder="请选择收款单位" disabled/>
              <j-dict-select-tag :disabled=formDisabled type="list" v-else-if="model.frectunittype=='BD_Empinfo'" v-model="model.frectunitdata" dictCode="erp_employee_file,name,employee_no" placeholder="请选择收款单位" disabled/>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="8">
            <a-form-model-item label="来源系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fsourcesystem">
              <a-input :disabled=formDisabled v-model="model.fsourcesystem" :max-length="36"  placeholder="请输入来源系统"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="业务类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fbusinesstype">
              <a-input :disabled=formDisabled v-model="model.fbusinesstype" :max-length="36"  placeholder="请输入业务类型"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="是否期初单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fisinit">
              <a-input :disabled=formDisabled v-model="model.fisinit" :max-length="36"  placeholder="请输入是否期初单据"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="付款金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpayamountfor">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpayamountfor" placeholder="请输入付款金额" style="width: 100%" />
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="本位币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fmainbookid">
              <a-input :disabled=formDisabled v-model="model.fmainbookid" :max-length="36"  placeholder="请输入本位币"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="结算币别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fsettlecur">
              <a-input :disabled=formDisabled v-model="model.fsettlecur" :max-length="36"  placeholder="请输入结算币别"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="应付金额本位币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpaytotalamountH">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpaytotalamountH" placeholder="请输入应付金额本位币" style="width: 100%" />
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="付款金额本位币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fpayamount">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.fpayamount" placeholder="请输入付款金额本位币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="实付金额本位币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frealpayamountH">
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="2" v-model="model.frealpayamountH" placeholder="请输入实付金额本位币" style="width: 100%" />
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="是否其他预付" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fisborrow">
              <a-input :disabled=formDisabled v-model="model.fisborrow" :max-length="36"  placeholder="请输入是否其他预付"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="是否同步" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isSync">
              <a-input :disabled=formDisabled v-model="model.isSync" :max-length="36"  placeholder="请输入是否同步"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="erp单据id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="erpBillId">
              <a-input :disabled=formDisabled v-model="model.erpBillId" :max-length="36"  placeholder="请输入erp单据id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="erp单据类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="erpBillType">
              <a-input :disabled=formDisabled v-model="model.erpBillType" :max-length="36"  placeholder="请输入erp单据类型"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="8">
            <a-form-model-item label="项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fqaspassistant1">
              <j-dict-select-tag :disabled=formDisabled type="list" v-model="model.fqaspassistant1" dictCode="erp_finance_kingdee_base_information,fdatavalue,fnumber" placeholder="请选择项目" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="对公对私" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fszsmdgds">
              <a-input :disabled=formDisabled v-model="model.fszsmdgds" :max-length="36"  placeholder="请输入对公对私"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fremark">
              <a-textarea :disabled="formDisabled" v-model="model.fremark" rows="4" placeholder="请输入备注"  :max-length="500"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fmklqlargetext1">
              <a-textarea :disabled="formDisabled" v-model="model.fmklqlargetext1" rows="4" placeholder="请输入备注"  :max-length="500"/>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="8">
            <a-form-model-item label="核算业务类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fqaspAssistant">
              <a-input :disabled=formDisabled v-model="model.fqaspAssistant" :max-length="36"  placeholder="请输入核算业务类型"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="8">
            <a-form-model-item label="单据状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fdocumentstatus">
              <a-input :disabled=formDisabled v-model="model.fdocumentstatus" :max-length="36"  placeholder="请输入单据状态"  ></a-input>
            </a-form-model-item>
          </a-col> -->
        </a-row>
      </a-collapse-panel>
      <a-collapse-panel key="2" header="付款单-付款单明细">
        <a-row>
          <a-col :span="24">
            <a-table
              ref="table"
              size="middle"
              rowKey="id"
              :components="draggableComponent"
              :loading="loading"
              bordered
              :columns="columns"
              :pagination="false"
              :data-source="model.fpaybillentry"
              :scroll="{x:scrollX}"
              >
              <template slot="fszsmcbsdzhd" slot-scope="text">
                <a :href="text" target="_blank" v-if="text && text!=' '">下载电子回单</a>
              </template>
              <span slot="projectId" slot-scope="text, record">
                <a @click="goProjectDetail(record)">{{ loadProjectId(text) }}</a>
              </span>
              <span slot="relReimbursementBillId" slot-scope="text, record">
                <a @click="goReimbursementDetail(record)">{{ loadReimbursement(text) }}</a>
              </span>
              <span slot="action" slot-scope="text, record">
                <template v-if="!formDisabled">
                        <a-button
                            class="ruleButton"
                            :ghost="true"
                            type="primary"
                            icon="edit"
                            @click="handleEdit(record)"/>
                        <a-divider type="vertical"/>
                        <a-popconfirm title="确定复制行吗?" @confirm="() => handleCopy(record)">
                          <a-button
                            class="ruleButton"
                            :ghost="true"
                            type="primary"
                            icon="copy"
                          />
                        </a-popconfirm>
                        <a-divider type="vertical"/>
                        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                            <a-button
                                class="ruleButton"
                                :ghost="true"
                                type="primary"
                                icon="delete"
                            />
                        </a-popconfirm>
                </template>
                </span>
            </a-table>
          </a-col>
        </a-row>
      </a-collapse-panel>
        <!-- <a-collapse-panel key="3" header="付款单-附件">
          <a-row :gutter="48">
            <a-col :span="24">
              <a-form-model-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachments">
                <j-upload :disabled="formDisabled" v-model="model.attachments"></j-upload>
              </a-form-model-item>
            </a-col>
          </a-row>
      </a-collapse-panel> -->
        </a-collapse>
      </a-form-model>
      <ErpFinanceKingdeePaymentDetailModal ref="itemList" @ok="modalFormOk" ></ErpFinanceKingdeePaymentDetailModal>
      <ErpFinanceReimbursementPenetrate  ref="reimbursementPenetrate"></ErpFinanceReimbursementPenetrate>
    <ErpFinanceLoanBillPenetrate ref="loanBillPenetrate" ></ErpFinanceLoanBillPenetrate>
    <ErpFinancePaymentBillPenetrate ref="paymentBillPenetrate" ></ErpFinancePaymentBillPenetrate>
    <ErpFinanceDepositBillPenetrate ref="projectDepositBillPenetrate" ></ErpFinanceDepositBillPenetrate>
    <ErpFinanceTraveBillPenetrate ref="traveBillPenetrate" ></ErpFinanceTraveBillPenetrate>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
  import { filterMultiDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
  import moment from 'moment'
  import { mapGetters } from 'vuex'
  import { DragResizable } from '@/mixins/DragResizable'
  import ErpFinanceKingdeePaymentDetailModal from './ErpFinanceKingdeePaymentDetailModal'
  import {pushIfNotExist, randomNumber, randomUUID} from '@/utils/util'

  export default {
    name: 'ErpFinanceKingdeePaymentBillForm',
    components: {
      SelectUserByDep,
      SelectTeamInput,
      SelectCompanyInput,
      SelectCustomerInput,
      ErpFinanceKingdeePaymentDetailModal,
      ErpFinanceReimbursementPenetrate: () => import('@/views/scy/penetrate/ErpFinanceReimbursementPenetrate'),
      ErpFinanceLoanBillPenetrate: () => import('@/views/scy/penetrate/ErpFinanceLoanBillPenetrate'),
      ErpFinancePaymentBillPenetrate: () => import('@/views/scy/penetrate/ErpFinancePaymentBillPenetrate'),
      ErpFinanceDepositBillPenetrate: () => import('@/views/scy/penetrate/ErpFinanceDepositBillPenetrate'),
      ErpFinanceTraveBillPenetrate: () => import('@/views/scy/penetrate/ErpFinanceTraveBillPenetrate')
    },
    mixins: [DragResizable],
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        activeKey:[1,2,3],
        loading: false,
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          querylist: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentDetail/list",
          add: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentBill/add",
          edit: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentBill/edit",
          queryById: "/api/erp/finance/kingdee/erpFinanceKingdeePaymentBill/queryById"
        },
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'结算方式',
            align:"center",
            width: 100,
            dataIndex: 'fsettletypeiddata_dictText',
          },
          {
            title:'付款用途',
            align:"center",
            width: 180,
            dataIndex: 'fpurposeiddata_dictText',
          },
          {
            title:'项目',
            align:"center",
            width: 100,
            dataIndex: 'fxyhgassistant_dictText',
          },
          {
            title:'应付金额',
            align:"center",
            width: 150,
            dataIndex: 'fpaytotalamountfor',
          },
          
          // {
          //   title:'付款金额本位币',
          //   align:"center",
          //   width: 80,
          //   dataIndex: 'fpayamounte',
          // },
          // {
          //   title:'付款金额',
          //   align:"center",
          //   width: 80,
          //   dataIndex: 'fpayamountfore',
          // },
          {
            title:'对方账户名称',
            align:"center",
            width: 180,
            dataIndex: 'foppositeccountname',
          },
          {
            title:'对方银行账号',
            align:"center",
            width: 180,
            dataIndex: 'foppositebankaccount',
          },
          {
            title:'对方开户行',
            align:"center",
            width: 180,
            dataIndex: 'foppositebankname',
          },
          // {
          //   title:'折后金额',
          //   align:"center",
          //   width: 100,
          //   dataIndex: 'fsettlepayamountfor',
          // },
          // {
          //   title:'未核销金额',
          //   align:"center",
          //   width: 80,
          //   dataIndex: 'fnotverificateamount',
          // },
          {
            title:'我方银行账号',
            align:"center",
            width: 180,
            dataIndex: 'faccountiddata',
          },
          {
            title:'备注',
            align:"center",
            width: 200,
            dataIndex: 'fcomment',
            
          },
          
          {
            title:'费用承担部门',
            align:"center",
            width: 250,
            dataIndex: 'fexpensedeptidE_dictText',
          },
          {
            title:'费用项目',
            align:"center",
            width: 100,
            dataIndex: 'fcostiddata_dictText',
          },
          {
            title:'电子回单',
            align:"center",
            width: 100,
            dataIndex: 'fszsmcbsdzhd',
            scopedSlots: { customRender: 'fszsmcbsdzhd' },
          },
          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   align: 'center',
          //   fixed: 'right',
          //   width: 110,
          //   scopedSlots: {
          //   filterDropdown: 'filterDropdown',
          //   filterIcon: 'filterIcon',
          //   customRender: 'action' }
          // }
        ]
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      //加载数据字典信息
      // this.initDictConfig();
      this.customKey = 'columns'
      this['columns'+'width'] = this[this.customKey].map(val => {
        return val.width
      })
    },
    methods: {
      // 加载穿透表单
      goDetail(record) {
        if (record.erpBillType == '1') {
          this.$refs.reimbursementPenetrate.initData(record.erpBillId);
          this.$refs.reimbursementPenetrate.visible = true;
        } else if (record.erpBillType == '2') {
          this.$refs.traveBillPenetrate.initData(record.erpBillId);
          this.$refs.traveBillPenetrate.visible = true;
        } else if (record.erpBillType == '3') {
          this.$refs.paymentBillPenetrate.initData(record.erpBillId);
          this.$refs.paymentBillPenetrate.visible = true;
        } else if(record.erpBillType == '4'){
          this.$refs.projectDepositBillPenetrate.initData(record.erpBillId);
          this.$refs.projectDepositBillPenetrate.visible = true;
        }else if(record.erpBillType == '5'){
          this.$refs.loanBillPenetrate.initData(record.erpBillId);
          this.$refs.loanBillPenetrate.visible = true;
        }
      },
      ...mapGetters(['userInfo']),
      add () {
        this.edit(this.modelDefault);
      },
      initDictConfig() {
      },
      edit (record) {
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        getAction(this.url.querylist, {billId:record.id}).then((res) => {
          if (res.success) {
            let result=res.result.records;
            if(result){
              this.$set(this.model,"fpaybillentry",result);
            }
          }
        })
      },
      //子表编辑
      handleEdit(record) {
        //是否关联合同的标识
        this.$refs.itemList.edit(record);
        this.$refs.itemList.title = '修改';
        this.$refs.itemList.disableSubmit = false;
      },
      // 子表复制行
    handleCopy(record) {
      let model = Object.assign({}, record);
      model.id = randomUUID();
      this.model.fpaybillentry.push(JSON.parse(JSON.stringify(model)))
    },
    // 子表删除
    handleDelete(id) {
      for (let i = 0; i < this.model.fpaybillentry.length; i++) {
        if (this.model.fpaybillentry[i].id == id) {
          this.model.fpaybillentry.splice(i, 1);
        }
      }
    },
    modalFormOk(data) {
      this.loading = true;
      let flag = true;
      // debugger;
      for (let i = 0; i < this.model.fpaybillentry.length; i++) {
        if (this.model.fpaybillentry[i].id == data.id) {
          this.model.fpaybillentry.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.model.fpaybillentry.push(data);
      }
      this.loading = false;
    },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
                that.$emit('unButtonDisable');
              }
            }).catch((error)=>{
               that.$emit('unButtonDisable');
             }).finally(() => {
               that.confirmLoading = false;
             })
          }else {
           that.$emit('unButtonDisable');
          }

        })
      },
    }
  }
</script>
